﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using NUnit.Framework;

namespace WindsorInitConfig {
    [TestFixture]
    public class Throttle {
        [Test]
        public void tt() {
            var actions = Enumerable.Repeat(new Action(DoStuff), 10)
                .Intersperse(new Action(() => Thread.Sleep(1000)));
            foreach (var a in actions)
                a();
        }

        public void DoStuff() {
            Console.WriteLine("I'm doing stuff");
        }
    }

    public static class EnumerableExtensions {
        public static IEnumerable<T> Intersperse<T>(this IEnumerable<T> source, T element) {
            var first = true;
            foreach (var value in source) {
                if (!first) yield return element;
                yield return value;
                first = false;
            }
        }
    }
}